define(["../TwitterMessage/TwitterMessageWidget",
        "dojo/_base/declare",
   	 	"dijit/_WidgetBase",
   	 	"dijit/_Container"
        ], function (TwitterMessageWidget, declare, _WidgetBase, _Container) {
	
	return declare([_WidgetBase, _Container], {
		constructor: function () {
			var params = arguments[0] || {};
            this._last_child = null;
            this._children_num = 0;
            this._capasity = params['capasity'] || null;
        },
		pushTwit: function (twit) {
			var twitWidget = new TwitterMessageWidget(twit);
			if (this._last_child === null) {
				this._last_child = twitWidget;
			}
			this.addChild(twitWidget, "first");
			this._children_num ++;
			if (this._capasity !== null && this._children_num > this._capasity) {
				this.popTwit().destroyRecursive();
			}
		},
		popTwit: function () {
			var _last_child = this._last_child;
			if (_last_child) {
				this.removeChild(_last_child);
				return _last_child;
			}
		}
	});
});